﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DeliverGoodsManagement_PrintDeliverBillWindow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Ajax.Utility.RegisterTypeForAjax(typeof(DeliverGoodsManagement_PrintDeliverBillWindow));
            lblOperator.Text = Share.UserValue(0);
            lblPrintDate.Text = DateTime.Now.ToString();
        }


    }
    #region 返回前台初始化数据
    [Ajax.AjaxMethod]
    public DataSet GetData(string value)
    {
        if (value != "")
        {
            try
            {
                string strOrderId = value.Replace("|", ",");
                DataSet ds = new BLL.ORDERDOC().GetOrderToPrintDeliverBill(strOrderId);
                DataTable dt=new DataTable();
                
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    DataColumn c = new DataColumn();
                    c.ColumnName = col.ColumnName;
                    c.DataType = col.DataType;
                    dt.Columns.Add(c);
                }
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    DataRow r = dt.NewRow();
                    for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                    {
                        r[i] = row[i];
                    }
                    dt.Rows.Add(r);   
                }
                ds.Tables[0].Clear();
                string[] arrTmp=strOrderId.Split(',');
                foreach (string orderid in arrTmp)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        if (row["ORDER_ID"].ToString() == orderid)
                        {
                            DataRow r = ds.Tables[0].NewRow();
                            for (int i = 0; i < dt.Columns.Count; i++)
                            {
                                r[i] = row[i];
                            } 
                            ds.Tables[0].Rows.Add(r);
                        }
                    }
                }
                return ds;
            }
            catch (Exception ex)
            {
                return null;
            }

        }
        return null;
    }
    #endregion
}
